<?php

include('../lib/conn.php');

$username = $_REQUEST['username'];
$password = $_REQUEST['password'];

$sql = "select * from users where user_name='$username' and pass_word='$password'";

$result = $mysqli->query($sql);

if($result->num_rows>0){
    echo "<script>alert('用户名已存在');location.href='../html/regist.html';</script>";
    die;
}

$sql_ins = "insert into users(user_name,pass_word)values('$username','$password')";

$res = $mysqli->query($sql_ins);

if($res){
    echo "<script>alert('注册成功');location.href='../html/login.html';</script>";
}

?>


